//@author A0087294-unused
//because I coded GUI I have no files to show unit testing
//thus, I coded a mini project that mirrors the original project 
//with some user commands. This mini project has unit testing
//in it for grading purposes.

#include "testUnitTest.h"

int testUnitTest::size = 0; 
vector<string>* testUnitTest::list = new vector<string>;

//add

bool testUnitTest::addToVector(string newString){
	storeToVector(newString);
	return checkIfStored();
}

void testUnitTest::storeToVector(string newString){
	list->push_back(newString);
	size++;
}

bool testUnitTest::checkIfStored(){
	if(size == list->size()){
		return true;
	} else if (size != list->size()){
		return false;
	}
	return false;
}


//delete

bool testUnitTest::deleteFromVector(int index){
	if (checkIfValidIndex(index)){
		performDelete(index);
	} else if (!checkIfValidIndex(index)){
		return false;
	}
	return checkIfDeleted();	
}

bool testUnitTest::checkIfValidIndex(int index){
	if (index < 0 || index > list->size()){
		return false;
	} else if (index >= 0 && index <= list->size()){
		return true;
	}
	return false;
}

void testUnitTest::performDelete(int index){
	list->erase(list->begin()+(index-1));
	size--;
}

bool testUnitTest::checkIfDeleted(){
	if (size == list->size()){
		return true;
	} else if (size != list->size()){
		return false;
	}
	return false;
}


//edit

bool testUnitTest::editStringInVector(string editedString, int index){
	if (checkIfValidIndex(index)){
		editInVector(editedString, index);
	} else if (!checkIfValidIndex(index)){
		return false;
	}
	return checkIfEdited(editedString, index);
}

void testUnitTest::editInVector(string editedString, int index){
	(*list)[index-1] = editedString;
}

bool testUnitTest::checkIfEdited(string editedString, int index){
	if ((*list)[index-1] == editedString){
		return true;
	} else if ((*list)[index-1] != editedString){
		return false;
	}
	return false;
}
